/*
 * Rating.java
 *
 * This program demonstrates the use of for loop to rate an article.
 *
 */

package com.javacore.day3.article;

import java.util.Scanner;

/**
 *
 * @author 
 */

public class Rating {
    
    /** Creates a new instance of Rating */
    public Rating() {
    }
    
    /**
     * @param args the command line arguments
     */
    public static void main(String[] args) {
        int choice;
        int poorCount = 0, fairCount = 0, goodCount = 0, excellentCount = 0;
        
        Scanner input = new Scanner(System.in);
        
        System.out.println("Tell us what do you think about the content of" +
                " the article \"Basics of Java\".");
        System.out.println("1. Poor");
        System.out.println("2. Fair");
        System.out.println("3. Good");
        System.out.println("4. Excellent");
        System.out.println("5. Exit");
        
        System.out.println("\nEnter your choice:");
        choice = input.nextInt();
        
        // Iterate the loop until user enters 5
        for(;choice != 5;) {
            
            /* Increment the respective counters depending on the rating
               entered by the user */
            switch(choice) {
                
                case 1:
                    poorCount++;
                    break;
                    
                case 2:
                    fairCount++;
                    break;
                    
                case 3:
                    goodCount++;
                    break;
                    
                case 4:
                    excellentCount++;
                    break;
                    
                default:
                    System.out.println("Invalid input!");
                    break;
                    
            }
            System.out.println("\nEnter your choice:");
            choice = input.nextInt();
        }
        System.out.println("\nThe article \"Basics of Java\" has received " +
                "the following ratings:");
        System.out.println("Poor: " + poorCount);
        System.out.println("Fair: " + fairCount);
        System.out.println("Good: " + goodCount);
        System.out.println("Excellent: " + excellentCount);
    }
}
